/*
 *  $Id: ClearMind.cs 1220 2010-11-30 16:25:44Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Neutral.Abilities {
    public class ClearMind: PlayerAbilityCard<ChainData> {
        public ClearMind(): base("001_n_a_clear_mind") {
            Level = CompleteLevel.ReadyForTest;
            Version = 0;
            Element = ElementType.Neutral;
            Target = new ChainTarget(IsDifferentCard,
                new HandCardTarget(GetNewPhrase("target1"), HandCardTarget.IsOpened),
                new HandCardTarget(GetNewPhrase("target2"), HandCardTarget.IsOpened));
            AddCondition(new MeditationCondition(1, true));
        }

        private static readonly Languages.CardPhrase<ClearMind> DiffCards = new Languages.CardPhrase<ClearMind>("diff_cards");

        private static bool IsDifferentCard(TargetArgs<ChainData> args) {
            TargetArgs<HandCardData> c1, c2;
            if (!args.Target.GetArgs(out c1, out c2)) return false;
            if (c1.Target.Card == c2.Target.Card) {
                args.Player.Game.ErrorNotice(DiffCards.Phrase.GetText());
                return false;
            }
            return true;
        }

        protected override void DoAction(TargetArgs<ChainData> args) {
            TargetArgs<HandCardData> c1, c2;
            if (!args.Target.GetArgs(out c1, out c2)) return;
            args.Player.DropCards(c1.Target, c2.Target);
            args.Player.CardToHands(false, true);
        }
    }
}
